package com.cyzy.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

/**
 * 订单工具类
 */
public class OrderUtils {
    
    private static final String ORDER_PREFIX = "SCORE"; // Score积分订单前缀
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
    private static final Random RANDOM = new Random();
    
    /**
     * 生成积分订单号
     * 格式：SCORE + 年月日时分秒 + 4位随机数
     * @return 订单号
     */
    public static String generateScoreOrderNum() {
        String timestamp = LocalDateTime.now().format(FORMATTER);
        int randomNum = RANDOM.nextInt(9000) + 1000; // 生成1000-9999的随机数
        return ORDER_PREFIX + timestamp + randomNum;
    }
}